package com.syj.collect.adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.syj.collect.app.R;
import com.syj.collect.entry.MyCollectBean;
import com.syj.collect.model.ProjectDetailActivity;

import java.util.ArrayList;
import java.util.List;

public class MyCollectAdapter extends RecyclerView.Adapter<MyCollectAdapter.MyTaskViewHoder> {

private List<MyCollectBean.DataDTO.ListDTO> cList=new ArrayList<>();
    public MyCollectAdapter() {
    }

    @NonNull
    @Override
    public MyCollectAdapter.MyTaskViewHoder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view= LayoutInflater.from(parent.getContext()).inflate(R.layout.item_collect,parent,false);
        return new MyTaskViewHoder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull MyCollectAdapter.MyTaskViewHoder holder, int position) {
        //Glide.with(holder.itemView.getContext()).load(cList.get(position).)
        holder.tv_conent.setText(cList.get(position).getAddress()+"");
        holder.tv_data.setText(cList.get(position).getReportDate());
        holder.tv_title.setText(cList.get(position).getName());
        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ProjectDetailActivity.StartAction(holder.itemView.getContext(),cList.get(position).getId()+"");
            }
        });

    }

    @Override
    public int getItemCount() {
        return cList.size();
    }

    public void upDate(List<MyCollectBean.DataDTO.ListDTO> str) {
        cList.clear();
        cList.addAll(str);
        notifyDataSetChanged();

    }

    /**
     *
     */
    class MyTaskViewHoder extends RecyclerView.ViewHolder{
        TextView tv_type;
        TextView tv_data;
        TextView tv_conent;
        TextView tv_title;
        ImageView iv_left;
        public MyTaskViewHoder(@NonNull View itemView) {
            super(itemView);
            iv_left=itemView.findViewById(R.id.iv_left);
            tv_type=itemView.findViewById(R.id.tv_type);
            tv_data=itemView.findViewById(R.id.tv_data);
            tv_conent=itemView.findViewById(R.id.tv_conent);
            tv_title=itemView.findViewById(R.id.tv_title);
        }
    }
}
